package thread.pool;

import thread.ThreadUtils;

import java.beans.ExceptionListener;
import java.util.concurrent.*;

/*
自定义线程池
 */
public class TestThreadFactory {
    public static void main(String[] args) {
        ExecutorService executorService = new ThreadPoolExecutor(5, 10, 60L
                , TimeUnit.SECONDS, new ArrayBlockingQueue<>(50),
                Executors.defaultThreadFactory(),
                 (t,l)->{
                     System.out.println("线程溢出");
                 });
        for (int i = 0; i <1000 ; i++) {
            executorService.submit(() -> {
                ThreadUtils.sleep(1000);
                System.out.println("--------");
            });
        }
        executorService.shutdown();


    }

}
